package com.cie2.janji.entities;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.tapestry5.beaneditor.NonVisual;
import org.apache.tapestry5.beaneditor.Validate;


@Entity
@Table(name="promise")
public class Promise {

	public enum PromiseStatus {
		Unrealized, Keep, Broken, Extended
	}
	
	private Long id;
	
	private PromiseStatus status; 
	
	private BaseEntity entity;
	
	private String title;
	
	private Category category;
	
	private String abstraction;
	
	private User author;
	
	private String image;
	
	private Date startDate;

	private Date endDate;
	
	private boolean publish;
	
	private Date createdDate;
	
	private Date updatedDate;
	
	private Date publishDate;
	
	private String quote;
	
	private String urlReference;
	
	private Integer year;
	
	private Integer month;
	
	private Integer percentage;

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NonVisual
	public Long getId() {
		return id;
	}

	public String getTitle() {
		return title;
	}
	
	@Validate("required")
	public String getUrlReference() {
		return urlReference;
	}

    @ManyToOne(targetEntity=Category.class)
    @JoinColumn(name="CATEGORY_ID")
	public Category getCategory() {
		return category;
	}

	
    @ManyToOne(targetEntity=BaseEntity.class)
    @JoinColumn(name="BASE_ENTITY_ID")
	public BaseEntity getEntity() {
		return entity;
	}
	
    @Validate("max=200")
    @Column(columnDefinition="TEXT")
	public String getAbstraction() {
		return abstraction;
	}

    @Validate("max=1024")
    @Column(columnDefinition="TEXT")
	public String getQuote() {
		return quote;
	}
	

	@Validate("required")
	public PromiseStatus getStatus() {
		return status;
	}
	
	public Date getCreatedDate() {
		return createdDate;
	}

	public Integer getMonth() {
		return month;
	}

	public Integer getYear() {
		return year;
	}
	
	public Date getStartDate() {
		return startDate;
	}


	public Date getEndDate() {
		return endDate;
	}

	public String getImage() {
		return image;
	}

	public boolean isPublish() {
		return publish;
	}

	public Date getPublishDate() {
		return publishDate;
	}



	public Date getUpdatedDate() {
		return updatedDate;
	}
	
	
    @NonVisual
    public Integer getPercentage() {
		return percentage;
	}



	@ManyToOne(targetEntity=User.class)
    @JoinColumn(name="AUTHOR_ID")
	public User getAuthor() {
		return author;
	}

	public void setAbstraction(String abstraction) {
		this.abstraction = abstraction;
	}


	public void setCreatedDate(Date created_date) {
		this.createdDate = created_date;
	}

	public void setStartDate(Date date) {
		this.startDate = date;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}


	public void setEntity(BaseEntity entityId) {
		this.entity = entityId;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setImage(String photo) {
		this.image = photo;
	}

	public void setPublish(boolean publish) {
		this.publish = publish;
	}

	public void setPublishDate(Date publish_date) {
		this.publishDate = publish_date;
	}

	public void setQuote(String quote) {
		this.quote = quote;
	}


	public void setTitle(String title) {
		this.title = title;
	}

	public void setUpdatedDate(Date update_date) {
		this.updatedDate = update_date;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public void setUrlReference(String urlReference) {
		this.urlReference = urlReference;
	}

	public void setMonth(Integer month) {
		this.month = month;
	}

	public void setYear(Integer year) {
		this.year = year;
	}


	public void setStatus(PromiseStatus status) {
		this.status = status;
	}

	public void setCategory(Category category) {
		this.category = category;
	}
	
	public void setPercentage(Integer percentage) {
		this.percentage = percentage;
	}
}
